package com.gitee.cirnochat.login.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.gitee.cirnochat.common.model.enums.BaseEnum;
import lombok.Getter;

@Getter
public enum QrCodeStatus implements BaseEnum<Integer> {
    PENDING(0, "待扫描"),
    SCANNED(1, "已扫描"),
    EXPIRED(2, "已过期");

    @JsonValue
    @EnumValue
    private final Integer value;
    private final String description;

    QrCodeStatus(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public static QrCodeStatus fromValue(Integer value) {
        for (QrCodeStatus status : QrCodeStatus.values()) {
            if (status.getValue().equals(value)) {
                return status;
            }
        }
        return null; // 或者抛出异常
    }
}
